package com.donn.securitycontrolplatform.equipment.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.donn.securitycontrolplatform.common.Result;
import com.donn.securitycontrolplatform.equipment.entity.TEquipment;
import com.donn.securitycontrolplatform.equipment.service.ITEquipmentService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhenglx
 * @since 2022-06-19
 */
@RestController
@RequestMapping("/scp/api/equipment")
@Tag(name = "equipment-controller", description = "设备controller")
public class TEquipmentController {

    @Autowired
    ITEquipmentService service;

    @ApiOperation(value = "设备管理新增")
    @PostMapping("/add")
    @ResponseBody
    public Result add(@RequestBody @ApiParam(value = "设备管理对象") TEquipment tEquipment) {
        return service.insertTEquipment(tEquipment);
    }

    @ApiOperation(value = "设备管理修改")
    @PutMapping("/update")
    @ResponseBody
    public Result update(@RequestBody @ApiParam(value = "设备管理对象") TEquipment tEquipment) {
        return service.updateTEquipment(tEquipment);
    }

    @ApiOperation(value = "设备管理删除")
    @DeleteMapping("/delete")
    @ResponseBody
    public Result delete(@RequestParam @ApiParam(value = "设备id", required = true) String equipmentId) {
        return service.deleteTEquipment(equipmentId);
    }

    @ApiOperation(value = "设备详情")
    @GetMapping("/get")
    @ResponseBody
    public Result get(@RequestParam @ApiParam(value = "设备id", required = true) String equipmentId) {
        return service.geTEquipmentById(equipmentId);
    }


    @ApiOperation(value = "查询列表")
    @GetMapping("/list")
    @ResponseBody
    public Result list(TEquipment tEquipment, Page page) {
        return service.selectTEquipmentList(tEquipment, page);
    }


    @ApiOperation(value = "动态盘点")
    @GetMapping("/quantity/{fenceId}/")
    @ResponseBody
    public Result getQuantityBy(@PathVariable String fenceId, @RequestParam LocalDateTime startTime, @RequestParam LocalDateTime endTime) {
        return service.getQuantityBy(startTime, endTime);
    }
}
